#%%
import cv2
import numpy as np

img = np.zeros((8,8), dtype = np.uint8)

print("img = \n",img)
cv2.imshow("one",img)

print("读取像素点img[0,3]=",img[0,3])

img[0,3]=255
print("修改后的像素点img",img)

cv2.imshow("two",img)

cv2.waitKey()
cv2.destroyAllWindows()


#%%
# 生成三原色图

import numpy as np
import cv2 as cv

# 三通道都填充 0  ，表示黑色
black = np.zeros((300,300,3),dtype = np.uint8)

cv.imshow("color",black)

cv.waitKey()

# 同到顺序为BGR ，将第一个通道B填充为 255，表示填充蓝色  
blue =black
blue[:,:,0] =255
print("blue=\n",blue)
cv.imshow("blue",blue)
cv.waitKey()

green = np.zeros_like(black)
green[:,:,1]=255
cv.imshow("green",green)
cv.waitKey()

red = np.zeros_like(black)
red[:,:,2]=255
cv.imshow("red",red)

cv.waitKey()
cv.destroyAllWindows()



#%%

# 三通道图

import numpy as np
import cv2 as cv
img = np.zeros((300,300,3),dtype = np.uint8)
img[:,0:100,0]=255
img[:,100:200,1]=255
img[:,200:300,2]=255

cv.imshow("img",img)
cv.waitKey()
cv.destroyAllWindows()

#%%

# 生成随机彩色图
import numpy as np
import cv2 as cv

# 生成长为300，宽300，通道为3 ，
# 值域为[100,200) 的图片，
img = np.random.randint(100,200,size=[300,300,3],dtype = np.uint8)
cv.imshow("randImg",img)
cv.waitKey()
cv.destroyAllWindows()


